import java.io.*;
import java.nio.file.*;

public class StringExtractor {

    public static void main(String[] args) {
        // 确保提供了文件路径参数
        if (args.length < 1) {
            System.out.println("Usage: java StringExtractor <file_path>");
            return;
        }

        // 获取文件路径
        String filePath = args[0];

        // 读取文件并提取字符串
        extractStringsFromFile(filePath);
    }

    public static void extractStringsFromFile(String filePath) {
        Path path = Paths.get(filePath);
        try (BufferedReader reader = Files.newBufferedReader(path)) {
            String line;
            Boolean inString = false;
            Boolean escapeNext = false;
            StringBuilder currentString = new StringBuilder();

            while ((line = reader.readLine()) != null) {
                for (int i = 0; i < line.length(); i++) {
                    char c = line.charAt(i);

                    if (escapeNext) {
                        currentString.append(c);
                        escapeNext = false;
                        continue;
                    }

                    if (c == '\\') {
                        escapeNext = true;
                        continue;
                    }

                    if (c == '\"') {
                        if (inString && i + 1 < line.length() && line.charAt(i + 1) == '\"') {
                            // 处理转义的双引号
                            currentString.append('\"');
                            i++; // 跳过下一个双引号
                        } else {
                            // 字符串开始或结束
                            inString = !inString;
                            if (!inString && currentString.length() > 0) {
                                // 输出提取的字符串
                                System.out.println(currentString.toString());
                                currentString.setLength(0); // 重置StringBuilder
                            }
                        }
                    } else if (inString) {
                        currentString.append(c);
                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}